class Dog:

    def __init__(self, age):
        self.__age = age

    def set_age(self, new_age):
        if new_age > 0 and new_age <= 100:
            self.__age = new_age
        else:
            print("年龄有误")

    def get_age(self):
        return self.__age


dog = Dog(10)

dog.set_age(20)
print(dog.get_age())

dog.set_age(-10)  # 修改对象的属性
print(dog.get_age())

# age = dog.get_age()   #查看对象的属性
# print(age)

# dog.get_name()
